package com.huawei.appmarket.service.hifolder;

import android.app.Activity;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appmarket.framework.startevents.protocol.view.ShowProtocolChangeActivity;
import com.huawei.appmarket.framework.startevents.protocol.view.ShowTermsActivity;
import com.huawei.hwid.core.constants.HwAccountConstants;
import java.util.HashMap;
import java.util.Map;
import o.awo;
import o.dhq;
import o.dij;
import o.diq;
import o.diu;
import o.Logger;
import o.ContentManager;
import o.eaf;
import o.eag.b;

public class ProtocolCheckService extends Service {
    private eaf ˊ;
    private b ˋ = new b(this) {
        final /* synthetic */ ProtocolCheckService ˋ;

        {
            this.ˋ = r1;
        }

        public void ॱ(eaf o_eaf) {
            Logger.ˏ("ProtocolCheckService", "checkProtocl");
            this.ˋ.ˊ = o_eaf;
            if (UserSession.getInstance().isLoginSuccessful()) {
                new dij(null, new e()).ˏ(new d());
                return;
            }
            boolean ˎ = diu.ˊ().ˎ();
            Map hashMap = new HashMap();
            hashMap.put("hifolder_protocol_result", Boolean.valueOf(ˎ));
            try {
                this.ˋ.ˊ.ˎ(hashMap);
            } catch (RemoteException e) {
                Logger.e("ProtocolCheckService", "checkProtocl RemoteException");
            }
        }
    };

    class d extends diq {
        final /* synthetic */ ProtocolCheckService ˊ;

        private d(ProtocolCheckService protocolCheckService) {
            this.ˊ = protocolCheckService;
        }

        public void ˋ(Activity activity) {
            super.ˋ(activity);
            Logger.ˎ("ProtocolCheckService", "ProtocolCheckServiceactivity is null send broadcast onUpgrade");
            if (this.ˊ.ˊ != null) {
                PendingIntent ˎ = ˎ();
                Map hashMap = new HashMap();
                hashMap.put("hifolder_pending_intent", ˎ);
                try {
                    this.ˊ.ˊ.ˎ(hashMap);
                } catch (RemoteException e) {
                    Logger.e("ProtocolCheckService", "onUpgrade RemoteException");
                }
            }
        }

        private PendingIntent ˎ() {
            Context ˋ = ContentManager.getInstant().getContext();
            Intent intent = new Intent(ˋ, ShowProtocolChangeActivity.class);
            intent.putExtra("service_type", 99);
            intent.putExtra("view_type", 1);
            return PendingIntent.getActivity(ˋ, 1, intent, HwAccountConstants.FLAG_TRANS_NAVIGATION_BAR);
        }

        public void ॱ(Activity activity) {
            super.ॱ(activity);
            Logger.ˎ("ProtocolCheckService", "ProtocolCheckServiceactivity is null send broadcast onNotSign");
            if (this.ˊ.ˊ != null) {
                PendingIntent ˏ = ˏ();
                Map hashMap = new HashMap();
                hashMap.put("hifolder_pending_intent", ˏ);
                try {
                    this.ˊ.ˊ.ˎ(hashMap);
                } catch (RemoteException e) {
                    Logger.e("ProtocolCheckService", "onNotSign RemoteException");
                }
            }
        }

        private PendingIntent ˏ() {
            Context ˋ = ContentManager.getInstant().getContext();
            Intent intent = new Intent(ˋ, ShowTermsActivity.class);
            intent.putExtra("view_type", 1);
            intent.putExtra("service_type", 99);
            return PendingIntent.getActivity(ˋ, 0, intent, HwAccountConstants.FLAG_TRANS_NAVIGATION_BAR);
        }

        public void ˎ(Activity activity) {
            super.ˎ(activity);
        }
    }

    class e implements awo {
        final /* synthetic */ ProtocolCheckService ˋ;

        private e(ProtocolCheckService protocolCheckService) {
            this.ˋ = protocolCheckService;
        }

        public void ˋ(boolean z) {
            Logger.ˎ("ProtocolCheckService", " isAgreeProGlobal=" + z);
            if (z) {
                dhq.ॱ().ˋ();
            } else {
                dhq.ॱ().ˊ();
            }
            if (this.ˋ.ˊ != null) {
                Map hashMap = new HashMap();
                hashMap.put("hifolder_protocol_result", Boolean.valueOf(z));
                try {
                    this.ˋ.ˊ.ˎ(hashMap);
                } catch (RemoteException e) {
                    Logger.e("ProtocolCheckService", "onCheckResult RemoteException");
                }
            }
        }
    }

    public IBinder onBind(Intent intent) {
        Logger.ˏ("ProtocolCheckService", "onBind service");
        return this.ˋ;
    }
}
